import argparse
from ast import parse

def configure():

    parser = argparse.ArgumentParser()

    ## common setting

    parser.add_argument('--exp_type', type=str, default='untarget', help='the experiment type', choices=['untarget', 'target', 'variant', 'param', 'multiple', 'robust', 'transfer', 'highdim', 'gaussian'])
    parser.add_argument('--exp_case', type=str, default='performance', help='for target/untarget attack: case_1_2, latex,...; for robust:..., for ....')
    parser.add_argument('--exp_obj', type=str, default='MPack', help='the attack method')

    parser.add_argument('--epsilon', type=float, default=0.05, help='the upperBound of epsilon')
    parser.add_argument('--attck_norm', type=str, default='inf', help='inf: L_inf norm, l2: L_2 norm')
    parser.add_argument('--attck_method', type=str, default='integer', help='float: raneg form [-epsilon, epsilon], integer: range from {-epsilon, 0, epsilon}')

    parser.add_argument('--attack_num', type=int, default=500, help='the attack number')

    ## Config parameters for stage I to generate base samples
    parser.add_argument('--population_size', type=int, default=50, help='the population size for stage I')
    parser.add_argument('--generation', type=int, default=500, help='the evolution generations')
    parser.add_argument('--base_size', type=int, default=10, help='the number of base sample size')
    parser.add_argument('--base_batch', type=int, default=16, help='the number of base batch for generating one sample')
    parser.add_argument('--base_mode', type=str, default='independent', help='cross: sample can be repeat use,  independent: base smaple have no cross')
    parser.add_argument('--alpha', type=float, default=0.9, help='the mutation cof')
    parser.add_argument('--total_num', type=int, default=80, help='the total ref samples')
    parser.add_argument('--F', type=float, default=0.5, help='differential evolution param')
    parser.add_argument('--CR', type=float, default=0.6, help='differential evolution param')


    ## Config parameters for stage II to generate adversarial samples
    parser.add_argument('--FES', type=int, default=10000, help='the maximum evaluation function query times')
    
    ## transfer ability
    parser.add_argument('--transfer_model_arch', type=str, default='ResNet18', help='test the transfer ability')

    ## hign dimension problem
    parser.add_argument('--block_size', type=int, default=1, help='reduce the input dimension for hign dimension dataset such as ImageNet, where the block size: 2*2, 3*3, 4*4, if 1*1, means no reduction')
    
    ## Gaussian Augmentation
    parser.add_argument('--sigma', type=float, default=0.1, help='Gaussian noise inject into model to train a noise robust model')
    
    ## Config parameters for Network
    parser.add_argument('--lr', type=float, default=0.1, help='the learning rate for the network')
    parser.add_argument('--epochs', type=int, default=150, help='training epochs')
    parser.add_argument('--batch_size', type=int, default=128, help='training batch size')
    parser.add_argument('--dataset', type=str, default='CIFAR-10', help='experiment dataset: CIFAR-10, MNIST')
    parser.add_argument('--model_arch', type=str, default='VGG16', help='model architecture: CNN VGG16 ResNet18 adv_ResNet18')

    ## device config
    parser.add_argument('--gpu_id', type=int, default=0, help='chose the GPU id')

    ## buffer param
    parser.add_argument('--source', type=int, default=0)

    args = parser.parse_args()

    return args